{{ header }} 
{% if categories %} 
<div class="container visible-xs">
  <nav id="menu" class="navbar">
    <div class="navbar-header"><span id="category" class="visible-xs">{{ text_blog_category }}</span>
      <button type="button" class="btn btn-navbar navbar-toggle" data-toggle="collapse" data-target=".navbar-ex2-collapse"><i class="fa fa-bars"></i></button>
    </div>
    <div class="collapse navbar-collapse navbar-ex2-collapse">
      <ul class="nav navbar-nav">
        {% for category in categories %} 
        {% if category.children %} 
        <li class="dropdown"><a href="{{ category.href }}" class="dropdown-toggle" data-toggle="dropdown">{{ category.name }}</a>
          <div class="dropdown-menu">
            <div class="dropdown-inner">
              {% for children in category %} 
              <ul class="list-unstyled">
                <li><a href="{{ children.href }}">{{ children.name }}</a></li>
              </ul>
              {% endfor %}
            </div>
          </div>
        </li>
        {% else %}   
        <li><a href="{{ category.href }}">{{ category.name }}</a></li>
        {% endif %} 
        {% endfor %} 
      </ul>
    </div>
  </nav>
</div>
{% endif %} 
<div class="container">
  <ul class="breadcrumb">
    {% for breadcrumb in breadcrumbs %} 
    <li><a href="{{ breadcrumb.href }}">{{ breadcrumb.text }}</a></li>
    {% endfor %} 
  </ul>
  <div class="row">{{ column_left }} 
    {% if column_left and column_right %}
    {% set class = 'col-sm-6' %}
    {% elseif column_left or column_right %}
    {% set class = 'col-sm-9' %}
    {% else %}
    {% set class = 'col-sm-12' %}
    {% endif %}  
     
    <div id="content" class="{{ class }}">{{ content_top }} 
    
      {% if cms_blog_show_image %} 
        {% if thumb %} 
        <div><img src="{{ thumb }}" alt="{{ title }}" title="{{ title }}" class="img-thumbnail" /></div>
        {% endif %} 
      {% endif %} 
          
      <h1>{{ title }}</h1>
      
      <div>
		
		  	{% if cms_blog_show_author  %} 
			<span><i class="fa fa-pencil"></i> <b>{{ text_written_by }}</b> {{ author }}</span> 
			{% endif %} 
			
			{% if cms_blog_show_created_date  %} 
			<span><i class="fa fa-calendar"></i> <b>{{ text_created_date }}</b> {{ created }}</span> 
			{% endif %} 
			
			
			{% if cms_blog_show_hits  %} 
			<span><i class="fa fa-insert-template"></i> <b>{{ text_hits }}</b> {{ hits }}  </span>
			{% endif %} 		
			

			
			{% if cms_blog_show_comment_counter  %} 
			<span><i class="fa fa-comment"></i> <b>{{ text_comment_count }}</b> {{ comment_count }}  </span>
			{% endif %} 	
			
		
		  </div>
          
      {{ description }} 
      
      {% if related_blogs %} 
      <h3>{{ text_related_blog }}</h3>
      <div class="list-group">
      	{% for related_blog in related_blogs %} 
      	<a href="{{ related_blog.href }}" class="list-group-item">{{ related_blog.title }}</a>
      	{% endfor %} 
      </div>
      {% endif %} 
      
      {% if products %} 
      <h3>{{ text_related_product }}</h3>
      <div class="row">
        {% set i = 0 %} 
        {% for product in products %} 
        {% if column_left  and  column_right %} 
		{% set class = 'col-lg-6 col-md-6 col-sm-12 col-xs-12' %}
        {% elseif  column_left  or  column_right %} 
		{% set class = 'col-lg-4 col-md-4 col-sm-6 col-xs-12' %}
        {% else %}   
		{% set class = 'col-lg-3 col-md-3 col-sm-6 col-xs-12' %}
        {% endif %} 
        
        <div class="{{ class }}">
          <div class="product-thumb transition">
            <div class="image"><a href="{{ product.href }}"><img src="{{ product.thumb }}" alt="{{ product.name }}" title="{{ product.name }}" class="img-responsive" /></a></div>
            <div class="caption">
              <h4><a href="{{ product.href }}">{{ product.name }}</a></h4>
              <p>{{ product.description }}</p>
              {% if product.rating %} 
              <div class="rating">
              {% for i in 1..5 %}
              {% if rating < i %}<span class="fa fa-stack"><i class="fa fa-star-o fa-stack-1x"></i></span>{% else %}<span class="fa fa-stack"><i class="fa fa-star fa-stack-1x"></i><i class="fa fa-star-o fa-stack-1x"></i></span>{% endif %}
              {% endfor %}
              </div>
               {% endif %}
              {% if product.price %}
              <p class="price"> {% if not product.special %}
                {{ product.price }}
                {% else %} <span class="price-new">{{ product.special }}</span> <span class="price-old">{{ product.price }}</span> {% endif %}
                {% if product.tax %} <span class="price-tax">{{ text_tax }} {{ product.tax }}</span> {% endif %} </p>
              {% endif %}
               
            </div>
            <div class="button-group">
              <button type="button" onclick="cart.add('{{ product.product_id }}', '{{ product.minimum }}');"><span class="hidden-xs hidden-sm hidden-md">{{ button_cart }}</span> <i class="fa fa-shopping-cart"></i></button>
              <button type="button" data-toggle="tooltip" title="{{ button_wishlist }}" onclick="wishlist.add('{{ product.product_id }}');"><i class="fa fa-heart"></i></button>
              <button type="button" data-toggle="tooltip" title="{{ button_compare }}" onclick="compare.add('{{ product.product_id }}');"><i class="fa fa-exchange"></i></button>
            </div>
          </div>
        </div>
        
        {% set i = i + 1 %} 
        {% endfor %} 
      </div>
      {% endif %} 
      
      {% if tags %}
      <p>{{ text_tags }}
      {% for i in 0..tags|length %}
      {% if i < (tags|length - 1) %} <a href="{{ tags[i].href }}">{{ tags[i].tag }}</a>,
      {% else %} <a href="{{ tags[i].href }}">{{ tags[i].tag }}</a> {% endif %}
      {% endfor %} </p>
      {% endif %}
       
      
      <!-- AddBaidu Share Button BEGIN -->
            <div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a title="分享到QQ空间" href="#" class="bds_qzone" data-cmd="qzone"></a><a title="分享到新浪微博" href="#" class="bds_tsina" data-cmd="tsina"></a><a title="分享到腾讯微博" href="#" class="bds_tqq" data-cmd="tqq"></a><a title="分享到人人网" href="#" class="bds_renren" data-cmd="renren"></a><a title="分享到微信" href="#" class="bds_weixin" data-cmd="weixin"></a><a title="分享到Facebook" href="#" class="bds_fbook" data-cmd="fbook"></a><a title="分享到Twitter" href="#" class="bds_twi" data-cmd="twi"></a><a title="分享到linkedin" href="#" class="bds_linkedin" data-cmd="linkedin"></a></div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{},"image":{"viewList":["qzone","tsina","tqq","renren","weixin","fbook","twi","linkedin"],"viewText":"分享到：","viewSize":"16"},"selectShare":{"bdContainerClass":null,"bdSelectMiniList":["qzone","tsina","tqq","renren","weixin","fbook","twi","linkedin"]}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
            <!-- AddBaidu Share Button END -->
      <hr>
      
      {% if comment_status %} 
        
          <form class="form-horizontal" id="form-comment">
            <div id="comment"></div>
            <h2>{{ text_write }}</h2>
            {% if comment_guest %} 
            <div class="form-group required">
              <div class="col-sm-12">
                <label class="control-label" for="input-name">{{ entry_name }}</label>
                <input type="text" name="name" value="" id="input-name" class="form-control" />
              </div>
            </div>
            <div class="form-group required">
              <div class="col-sm-12">

                <label class="control-label" for="input-comment">{{ entry_comment }}</label>
                <textarea name="text" rows="5" id="input-comment" class="form-control"></textarea>
                <div class="help-block">{{ text_note }}</div>
              </div>
            </div>
            {{ captcha }} 
            <div class="buttons clearfix">
              <div class="pull-right">
                <button type="button" id="button-comment" data-loading-text="{{ text_loading }}" class="btn btn-primary">{{ button_continue }}</button>
              </div>
            </div>
            {% elseif logged %} 
            <div class="form-group required">
              <div class="col-sm-12">
                <label class="control-label" for="input-comment">{{ entry_comment }}</label>
                <textarea name="text" rows="5" id="input-comment" class="form-control"></textarea>
                <div class="help-block">{{ text_note }}</div>
				<input type="hidden" name="name" value="{{ name }}" id="input-name" class="form-control" />
              </div>
            </div>
            {{ captcha }} 
            <div class="buttons clearfix">
              <div class="pull-right">
                <button type="button" id="button-comment" data-loading-text="{{ text_loading }}" class="btn btn-primary">{{ button_continue }}</button>
              </div>
            </div>
			{% else %}   
            {{ text_login }} 
            {% endif %} 
          </form>
      {% endif %}
       
      
      {{ content_bottom }}</div>
    {{ column_right }}</div>
</div>
<script type="text/javascript"><!--
$('#comment').delegate('.pagination a', 'click', function(e) {
    e.preventDefault();

    $('#comment').fadeOut('slow');

    $('#comment').load(this.href);

    $('#comment').fadeIn('slow');
});

$('#comment').load('index.php?route=blog/blog/comment&blog_id={{ blog_id }}');

$('#button-comment').on('click', function() {
	$.ajax({
		url: 'index.php?route=blog/blog/write&blog_id={{ blog_id }}',
		type: 'post',
		dataType: 'json',
		data: $("#form-comment").serialize(),
		beforeSend: function() {
			$('#button-comment').button('loading');
		},
		complete: function() {
			$('#button-comment').button('reset');
		},
		success: function(json) {
			$('.alert-success, .alert-danger').remove();

			if (json['error']) {
				$('#comment').after('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + '</div>');
			}

			if (json['success']) {
				$('#comment').after('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + '</div>');

				$('textarea[name=\'text\']').val('');
				$('#comment').load('index.php?route=blog/blog/comment&blog_id={{ blog_id }}');
			}
		}
	});
});

//--></script>
{{ footer }}  